{extend name="pc/admin/layout"/}
{block name="main"}
   <div class="g-1400 g-container" id="pjax-container">
        
<div class="bg-bai b rx3" id="vue-page">
<form id="form-config">
    <div class="t-v t-t">
        <div class="c-sidebar c-sidebar-h pb5 br">
            <div class="c-sidebar-title t-v hui bb">网站数据管理</div>
            <ul class="c-nav click-nav">
				<li><a href="{:url('pc/admin',['act'=>'data','s'=>'user_list'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>用户列表</div>
                </a></li>
				<li><a href="{:url('pc/admin',['act'=>'data','s'=>'qq_list'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>QQ列表</div>
                </a></li>
				<li class="active"><a href="{:url('pc/admin',['act'=>'data','s'=>'gg_list'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>公告列表</div>
                </a></li>
				<li><a href="{:url('pc/admin',['act'=>'data','s'=>'fz_list'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>分站列表</div>
                </a></li>
            </ul>
        </div>
		<div class="c-content bl">
            <div class="g-title t-v pl4 bb">
				<div class="col-8">
					<a class="btn btn-bai btn-md pl5 pr6 lan" href="{:url('pc/admin',['act'=>'add','s'=>'gg'])}">添加公告</a>
				</div>
			</div>
                <table class="table m-b-none default footable">
                            <thead>
                            <tr>
                                <th class="text-center">公告内容</th>
                                <th class="text-center">公告类型</th>
                                <th class="text-center">到期时间</th>
                                <th class="text-center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="row in list">
                                <td class="text-center">{{row.con}}</td>
                                <td v-if="row.type === 0" class="text-center lan">普通公告</td>
                                <td v-else-if="row.type === 1" class="text-center hong">广告推广</td>
                                <td v-else class="text-center lv">推荐链接</td>
                                <td v-if="row.enddate === null" class="text-center hui">无限期</td>
                                <td v-else class="text-center hui">{{row.enddate}}</td>
                                <td class="text-center">
								<a :href="'{:url('pc/admin',['act'=>'edit','s'=>'gg'])}?id='+row.id" data-pjax> 编辑</a>&nbsp;&nbsp;&nbsp
								<a @click="del(row.id)"> 删除</a></td>
                            </tr>
                            <tr>
                            </tbody>
                        </table>
        </div>
</div>
</form>
<div class="c-pagination o-h t-v">
        <div class="c-sidebar"></div>
        <div class="c-content h11 o-h g-btn t-v bt bl">
		<div class="col-12 h no g-btn g-minhide t-v t-r">
			<pagination ref="pagination" :total="total" :current_page="search.page" :page_size="search.pageSize"
                            @page-phange="pageChange"></pagination>
        </div>
		</div>
    </div>
</div>

    </div>
   {/block}
   {block name='foot'}
		<script>
                    new Vue({
                        el: '#vue-page',
                        data: {
                            search: {
                                page: 1,
                                pageSize: 10,
                            },
                            total: 0,
                            list: []
                        },
                        methods: {
                            pageChange: function (p) {
                                this.search.page = p;
                                this.loadList();
                            },
                            loadList: function () {
                                this.$refs.pagination.setCurrent(this.search.page);// 改变页码
                                var vue = this;
                                app.ajax("{:url('AdminAjax/ggList',['action'=>'list'])}", this.search, function (data) {
                                    if (data.code === 0) {
                                        vue.total = data.total;
                                        vue.list = data.list;
                                    } else {
                                        x.msg(data.message);
                                    }
                                })
                            },
                            del: function (id) {
                                if (!confirm('确认要删除此公告吗？')) return;
                                var vue = this;
                                app.ajax("{:url('AdminAjax/ggList',['action'=>'del'])}", {id: id}, function (data) {
                                    if (data.code === 0) {
                                        vue.loadList();
                                        x.msg(data.message)
                                    } else {
                                        x.msg(data.message)
                                    }
                                })
                            },
                        },
                        mounted: function () {
                            this.loadList();
                        }
                    })
                </script>
    {/block}